//
//  KBCompleteViewController.swift
//  LaiLang
//
//  Created by David on 2017/4/16.
//  Copyright © 2017年 David. All rights reserved.
//

import UIKit

class KBCompleteViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {

    var navigationBar: UINavigationBar!
    var tableView: UITableView!
    
    var classData: NSMutableArray?
    
    convenience init(classData: NSArray?){
        self.init()
        if classData != nil{
            self.classData = NSMutableArray(array: classData!)
        }
        
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        tableView = UITableView(frame: CGRect(x: 0, y: 44, width: view.frame.width, height: view.frame.height-44))
        tableView.tableFooterView = UIView(frame: CGRect.zero)
        tableView.delegate = self
        tableView.dataSource = self
        view.addSubview(tableView)
        
        navigationBar = UINavigationBar(frame: CGRect(x: 0, y: 0, width: self.view.frame.width, height: 64))
        view.addSubview(navigationBar)
        navigationBar.barStyle = .black
        navigationBar.tintColor = UIColor.white
        navigationBar.barTintColor = themeColor
        
        let navItem = UINavigationItem(title: "完善信息")
        navigationBar.pushItem(navItem, animated: true)
        navItem.rightBarButtonItem = UIBarButtonItem(title: "完成", style: .plain, target: self, action: #selector(KBCompleteViewController.submit))
        navItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .stop, target: self, action: #selector(KBCompleteViewController
            .dismissVC))
    }
    
    func submit(){
        
    }
    
    func dismissVC(){
        let alert = UIAlertController(title: "放弃", message: "课程将不会添加到课表中", preferredStyle: .alert)
        alert.addAction(UIAlertAction(title: "放弃", style: .default, handler: { (action) in
            self.dismiss(animated: true, completion: nil)
        }))
        alert.addAction(UIAlertAction(title: "不放弃", style: .cancel, handler: nil))
        present(alert, animated: true, completion: nil)
        
    }

    func numberOfSections(in tableView: UITableView) -> Int {
        return classData?.count ?? 0
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 4
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = UITableViewCell(style: .default, reuseIdentifier: "item")
        // 名称 时间 地点 教师
        
        
        switch indexPath.row {
        case 0:
            break
        case 1:
            break
        case 2:
            break
        case 3:
            break
        default:
            break
        }
        
        return cell
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
